home *** CD-ROM | disk | FTP | other *** search
/ The Big Day - Work Smarter - Learn How / The Big Day - Work Smarter - Learn How (Microsoft).BIN / maindeck_files / script.js < prev    next >
Text File  |  2001-02-06  |  33KB  |  1,190 lines

  1.  
  2. function LoadSld( slideId )
  3. {
  4.     if( !g_supportsPPTHTML ) return
  5.     if( slideId )
  6.         parent.SldUpdated(slideId)
  7.     g_origSz=parseInt(SlideObj.style.fontSize)
  8.     g_origH=SlideObj.style.posHeight
  9.     g_origW=SlideObj.style.posWidth
  10.     g_scaleHyperlinks=(document.all.tags("AREA").length>0)
  11.     if( g_scaleHyperlinks )
  12.         InitHLinkArray()
  13.     if( g_scaleInFrame||(IsWin("PPTSld") && parent.IsFullScrMode() ) )
  14.         document.body.scroll="no"
  15.     _RSW()
  16.     if( IsWin("PPTSld") && parent.IsFullScrMode() )    {
  17.         document.oncontextmenu=parent._CM;
  18.         self.focus()
  19.     }
  20. }
  21. function MakeSldVis( fTrans ) 
  22. {
  23.     fTrans=fTrans && g_showAnimation
  24.     if( fTrans )
  25.     {
  26.         if( g_bgSound ) {
  27.             idx=g_bgSound.indexOf(",");
  28.             pptSound.src=g_bgSound.substr( 0, idx );
  29.             pptSound.loop= -(parseInt(g_bgSound.substr(idx+1)));
  30.         }
  31.         SlideObj.filters.revealtrans.Apply()
  32.     }
  33.     SlideObj.style.visibility="visible"
  34.     if( fTrans )
  35.         SlideObj.filters.revealtrans.Play()
  36. }
  37. function MakeNotesVis() 
  38. {
  39.     if( !IsNts() ) return false 
  40.     SlideObj.style.display="none"
  41.     nObj = document.all.item("NotesObj")
  42.     parent.SetHasNts(0)
  43.     if( nObj ) { 
  44.         nObj.style.display=""
  45.         parent.SetHasNts(1)
  46.     }
  47.     return 1
  48. }
  49. function Redirect( frmId,sId )
  50. {
  51.     var str=document.location.hash,idx=str.indexOf('#')
  52.     if(idx>=0) str=str.substr(1);
  53.     if( window.name != frmId && ( sId != str) ) {
  54.         obj = document.all.item("Main-File")
  55.         window.location.href=obj.href+"#"+sId
  56.         return 1
  57.     }
  58.     return 0
  59. }
  60. function HideMenu() { if( frames["PPTSld"] && PPTSld.document.all.item("ctxtmenu") && PPTSld.ctxtmenu.style.display!="none" ) { PPTSld.ctxtmenu.style.display='none'; return true } return false }
  61. function IsWin( name ) { return window.name == name }
  62. function IsNts() { return IsWin("PPTNts") }
  63. function IsSldOrNts() { return( IsWin("PPTSld")||IsWin("PPTNts") ) }
  64. function SupportsPPTAnimation() { return( navigator.platform == "Win32" && navigator.appVersion.indexOf("Windows")>0 ) }
  65. function SupportsPPTHTML()
  66. {
  67.     var appVer=navigator.appVersion, msie=appVer.indexOf("MSIE "), ver=0
  68.     if( msie >= 0 )
  69.         ver=parseFloat( appVer.substring( msie+5, appVer.indexOf(";",msie) ) )
  70.     else
  71.         ver=parseInt(appVer)
  72.  
  73.     return( ver >= 4 && msie >= 0 )
  74. }
  75. var MHTMLPrefix = CalculateMHTMLPrefix(); 
  76. function CalculateMHTMLPrefix()
  77. {
  78.     if ( document.location.protocol == 'mhtml:') { 
  79.         href=new String(document.location.href) 
  80.         Start=href.indexOf('!')+1 
  81.         End=href.lastIndexOf('/')+1 
  82.         if (End < Start) 
  83.             return href.substring(0, Start) 
  84.         else 
  85.         return href.substring(0, End) 
  86.     }
  87.     return '';
  88. }
  89.  
  90. function _RSW()
  91. {
  92.     if( !g_supportsPPTHTML || IsNts() ||
  93.       ( !g_scaleInFrame && (( window.name != "PPTSld" ) || !parent.IsFullScrMode()) ) )
  94.         return
  95.  
  96.     cltWidth=document.body.clientWidth
  97.     cltHeight=document.body.clientHeight
  98.     factor=(1.0*cltWidth)/g_origW
  99.     if( cltHeight < g_origH*factor )
  100.         factor=(1.0*cltHeight)/g_origH
  101.  
  102.     newSize = g_origSz * factor
  103.     if( newSize < 1 ) newSize=1
  104.  
  105.     s=SlideObj.style
  106.     s.fontSize=newSize+"px"
  107.     s.posWidth=g_origW*factor
  108.     s.posHeight=g_origH*factor
  109.     s.posLeft=(cltWidth-s.posWidth)/2
  110.     s.posTop=(cltHeight-s.posHeight)/2
  111.  
  112.     if( g_scaleHyperlinks )
  113.         ScaleHyperlinks( factor )
  114. }
  115.  
  116. function _KPH()
  117.   if( IsNts() ) return;
  118.  
  119.   if( !parent.IsFramesMode() && event.keyCode == 27 && !parent.HideMenu() )
  120.     parent.window.close( self );
  121.   else if( event.keyCode == 32 )
  122.   {
  123.     if( window.name == "PPTSld" )
  124.       parent.PPTSld.DocumentOnClick();
  125.     else
  126.       parent.GoToNextSld();
  127.   }
  128. }
  129.  
  130. var g_HLinkArray = new Array();
  131.  
  132. function IMapAreaObj( areaObj, coords )
  133. {
  134.   this.areaObj = areaObj;
  135.   this.coords = coords;
  136. }
  137.  
  138. function InitHLinkArray()
  139. {
  140.   var appVer = navigator.appVersion;
  141.   var msie = appVer.indexOf ( "MSIE " )
  142.   var ver = 0;
  143.   if ( msie >= 0 )
  144.     ver = parseInt ( appVer.substring( msie+5 ) );
  145.  
  146.   linkNum = 0;
  147.  
  148.   for (i=0; i<document.all.tags("AREA").length; i++) {
  149.     areaObj = document.all.tags("AREA").item(i);
  150.     if( ( areaObj.id != "pptxscale" ) || ( ver > 4 ) )
  151.       g_HLinkArray[linkNum++] = new IMapAreaObj( areaObj, ParseCoords( areaObj.coords ) );
  152.   }
  153. }
  154.  
  155. function ScaleHyperlinks( factor )
  156. {   
  157.   for ( ii=0; ii< g_HLinkArray.length; ii++) {
  158.     coordsStr="";
  159.     imaObj = g_HLinkArray[ii];
  160.     for ( jj=0; jj < imaObj.coords.length-1; jj++ )
  161.         coordsStr += (imaObj.coords[jj]*factor) + ",";
  162.     coordsStr += (imaObj.coords[jj]*factor);
  163.     imaObj.areaObj.coords = coordsStr;
  164.   }
  165. }
  166.  
  167. function ParseCoords( coordsStr )
  168. {
  169.   var numArray = new Array();
  170.   var i = curPos = commaPos = 0;
  171.  
  172.   while ( ( commaPos = coordsStr.indexOf(",", curPos) ) != -1 ) { 
  173.     numArray[i++] = parseInt( coordsStr.substr( curPos, commaPos ) );
  174.     curPos = commaPos + 1;
  175.   }
  176.   numArray[i] = parseInt( coordsStr.substr( curPos ) );
  177.  
  178.   return numArray;
  179. }
  180.  
  181.  
  182. function PlaySound( href, loop ){
  183.     href= unescape(href);
  184.     if( window.event ) window.event.cancelBubble = true;
  185.     pptSound.src = href;
  186.     pptSound.loop = loop ? -1 : 0;
  187. }
  188. var AE_NONE = 0, AE_DIM = 1, AE_HIDE = 2, AE_HIDEIMDTLY = 3, LONG_INTERVAL = 10, SHORT_INTERVAL = 5, g_curAnim = null, g_vml = 0;
  189. function ParseAnimations(){
  190.     nr = document.all.tags("DIV").length;
  191.     while(nr > 0) {
  192.         rObj = document.all.tags("DIV").item(--nr);
  193.         if(rObj.style.cssText != null) {
  194.             build = rObj.style.cssText.indexOf("mso-build");
  195.             if(build >= 0)
  196.                 AddAnimation(rObj);
  197.         }
  198.     }
  199.     if(g_autoTrans){
  200.         totT=0, autoAnims=0;
  201.         rAnims=g_animManager.m_anims;
  202.         nBuilds=g_animManager.m_numBuilds;
  203.         for(x=nBuilds;x>0;x--)
  204.         if(-1 != rAnims[x].m_secs){
  205.             totT+=rAnims[x].m_secs;
  206.             autoAnims++;
  207.         }
  208.         time=g_transSecs-totT;
  209.         if(time<0) time=0;
  210.         time=time/(nBuilds-autoAnims+1);
  211.         for(x=nBuilds;x>0;x--)
  212.             if(-1 == rAnims[x].m_secs)
  213.                 rAnims[x].m_secs=time;
  214.     }
  215. }
  216. function AddAnimation(rObj){
  217.     a =new Animation();
  218.     a.m_obj =rObj;
  219.     a.m_oldc =rObj.color;
  220.     GetVal=rObj.style.getAttribute;
  221.     var t;
  222.     if( t=GetVal("mso-build") ) a.m_build=t-0;
  223.     if( t=GetVal("mso-build-after-action") ) a.m_aAct=t-0;
  224.     if( t=GetVal("mso-build-after-color") ) a.m_oldc=t;
  225.     if( t=GetVal("mso-build-auto-secs") ) a.m_secs=t-0;
  226.     if( t=GetVal("mso-build-avi") ) a.m_video=t;
  227.     if( t=GetVal("mso-build-dual-id") ) a.m_dId=t;
  228.     if( t=GetVal("mso-build-order") ) a.m_order=t-0;
  229.     if( t=GetVal("mso-build-sound-name") ) a.m_sound=t;
  230.  
  231.     g_animManager.AddAnimation(a);
  232. }
  233. function ShowVGXObj(rObj){
  234.     vmlId=null,ImgTag=null;
  235.     curObj=rObj;
  236.     sObj =document.all.item("SlideObj");
  237.     while(null == ImgTag && null != curObj && sObj != curObj){
  238.         ImgTag =curObj.children.tags("IMG").item(0);
  239.         curObj =(curObj.parentElement.tagName == "DIV") ? curObj.parentElement : null
  240.     }
  241.     if(null !=ImgTag)
  242.         vmlId =ImgTag.getAttribute("v:shapes");
  243.     if(null !=vmlId) {
  244.         idx =vmlId.indexOf(",");
  245.         if(idx > 0) vmlId =vmlId.substr(0, idx);
  246.         vgxObj =document.all.item(vmlId);
  247.         if((null != vgxObj) && (null != vgxObj.parentElement) && (vgxObj.parentElement.style.display != "none")){
  248.             vgxObj.parentElement.style.visibility = "visible";
  249.             ImgTag.style.visibility = "hidden";
  250.         }
  251.         else
  252.             rObj.style.visibility = "visible";
  253.     }
  254. }
  255. function AnimationManager(){
  256.     t=this;
  257.     t.m_anims=new Array();
  258.     t.m_numBuilds=0;
  259.     t.m_activeObj=null;
  260.     t.m_curBuild=1;
  261.     t.m_timer=-1;
  262.     t.m_objToHide=null;
  263.     t.m_objToDim=null;
  264.     t.m_colorToDim=-1;
  265.     t.m_isPlaying=0;
  266.     t.m_autoTimer=-1;
  267.     t.Peek=AM_Peek;
  268.     t.Next=AM_Next;
  269.     t.Previous=AM_Previous;
  270.     t.AddAnimation=AM_AddAnimation;
  271.     t.ShowShapes=AM_ShowShapes;
  272.     t.Swap=AM_Swap;
  273. }
  274. function AM_ShowShapes(){
  275.     for(x=this.m_numBuilds; x>0; x--){
  276.         if(g_vml)
  277.             ShowVGXObj(this.m_anims[x].m_obj);
  278.         aObj =this.m_anims[x].m_obj;
  279.         if(aObj)
  280.             aObj.style.visibility = "visible";
  281.     }
  282.     this.m_numBuilds =0;
  283. }
  284. function AM_Swap(cur){
  285.     rList =this.m_anims;
  286.     t =rList[cur+1];
  287.     rList[cur+1] =rList[cur];
  288.     rList[cur] =t;
  289. }
  290. function AM_AddAnimation(a){
  291.     this.m_anims[++this.m_numBuilds] = a;
  292.     this.m_curBuild =this.m_numBuilds;
  293.     cur =this.m_numBuilds;
  294.     if(a.m_order > 0){
  295.         while(cur-- > 1 && Math.abs(this.m_anims[cur+1].m_order) > Math.abs(this.m_anims[cur].m_order))
  296.             this.Swap(cur);
  297.     }
  298.     else {
  299.         while(